package cn.knight.feignclient;

import cn.knight.domain.User;
import feign.hystrix.FallbackFactory;

/*
 * 通过实现FallbackFactory接口的方式来进行兜底方法的创建，泛型为feign接口
 */
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return User.builder().id(-1L).desc("系统繁忙，请稍后再试").build();
            }
        };
    }
}
